﻿<!--#include file="conn.asp"-->
<%
set rs=server.createobject("adodb.recordset")
set rs2=server.CreateObject("ADODB.RecordSet")
classid=request("classid")
currentPage=cint(request("page"))
MaxPerPage=cint(request("MaxPerPage"))
rs.open "select * from diqu where id="&classid,conn,1,1
	    HTMLName=rs("filename")
      rs.close
	  if currentPage=1 then
filename=HTMLName
else
filename=HTMLName&"_"&currentPage
end if
newshu=newshuset 
sql="select * from diqu where id = '"&classid&"'"
rs.open sql,conn,1,1
if not rs.eof then
do while not rs.eof
   classid=rs("id")
   clssname=rs("diqu")
rs.MoveNext
loop
end if
rs.close
title=""&clssname&""
zm=zm&""&clssname&""



'################ 推荐漫画开始 ################
h=0
sql="select * from comics where tj=1 and dqid = "&classid&" order by id desc"
rs.open sql,conn,1,1
if rs.eof then
comic_tj=comic_tj&"<LI class=t1>还没有推荐的漫画</li>"
else
do while not rs.eof
titley=rs("mhmc")
hits=rs("hits")
h=h+1
comic_tj=comic_tj&"<LI class=t"&h&"><SPAN>"&rs("hits")&"</SPAN><A title="&rs("mhmc")&" href=""/comic/"&rs("id")&"/"" target=_blank>"&left(rs("mhmc"),10)&"</A> </li>"
if h>=15 then exit do
rs.movenext
loop
end if
rs.close

'################ 推荐漫画结束 ################

'################ 最近更新开始 ################
h=0
sql="SELECT * FROM zj WHERE id in (select max(id) from zj group by cid) ORDER BY id desc"       
rs.open sql,conn,1,1
if rs.eof then
comic_new=comic_new&"<LI class=t1>还没有推荐的漫画</li>"
else
do while not rs.eof
 set rs2=server.createobject("adodb.recordset")
sql2="select * from comics where id ="&rs("cid")&""
rs2.open sql2,conn,1,1
if not rs2.eof then
titley=rs2("mhmc")
end if
rs2.close
hits=rs("hits")
h=h+1
comic_new=comic_new&"<LI class=t"&h&"><SPAN>"&year(rs("adddate"))&"-"&month(rs("adddate"))&"-"&day(rs("adddate"))&"</SPAN><A title="&titley&" href=""/comic/"&rs("cid")&"/"" target=_blank>"&left(titley,5)&"</A> <EM>[<A class=red href=""/comic/"&rs("cid")&"/"&rs("id")&""" target=_blank>"&left(rs("zjmc"),5)&"</A>]</EM></li>"
if h>=15 then exit do
rs.movenext
loop
end if
rs.close

'################ 最近更新结束 ################
'################ 点击总排行开始 ################
h=0
sql="select * from comics where dqid = "&classid&" order by hits desc"
rs.open sql,conn,1,1
if rs.eof then
comic_hits="·还没有添加"
else
do while not rs.eof
titley=rs("mhmc")
hits=rs("hits")
h=h+1
comic_hits=comic_hits&"<LI class=t"&h&"><SPAN>"&rs("hits")&"</SPAN><A title="&rs("mhmc")&" href=""/comic/"&rs("id")&"/"" target=_blank>"&left(rs("mhmc"),10)&"</A> </li>"
if h>=14 then exit do
rs.movenext
loop
end if
rs.close

'################ 点击总排行结束 ################

'################ 漫画目录开始 ################
sql= "select * from comics where dqid = "&classid&" order by id  desc"
rs.open sql,conn,1,1
if rs.eof then
mpage=1
allshu=0
else
h=0
rs.pagesize=MaxPerPage 
mpage=rs.pagecount     
rs.move  (currentPage-1)*MaxPerPage
allshu=rs.recordcount
do while not rs.eof
sql2="SELECT * FROM zj where cid="&rs("id")&" order by id desc"       
rs2.Open sql2,conn,1,1
if rs2.eof then
zj_name=""
zjid=""
add_date=""
else
zjid=rs2("id")
zj_name=left(rs2("zjmc"),8)
add_date=rs2("adddate")
end if
rs2.close
id=rs("id")
list=list&"<LI><A title="&rs("mhmc")&" href=""/comic/"&rs("id")&"/"" target=_blank>"
list=list&"<IMG alt="""&rs("mhmc")&""" src=""/cpic/"&rs("mhfm")&""">"&left(rs("mhmc"),10)&"</A><span>"
list=list&"<A class="
if rs("zt")=true then
list=list&"green  title=最近更新时间:"&add_date&" href=""/comic/"&rs("id")&"/"&zjid&""" target=_blank>已完结</A></span></LI>"
else
list=list&"red  title=最近更新时间:"&add_date&" href=""/comic/"&rs("id")&"/"&zjid&""" target=_blank>最新:"&zj_name&"</A></span></LI>"
end if
rs.movenext
  h=h+1
if h>=MaxPerPage then exit do
loop

end if
rs.close
h=0
 set rs = nothing 
 set conn = nothing
'################ 漫画目录结束 ################

'################ 分页开始 ################

pageno=currentPage
pagefy=pagefy&"<font color=red>"&pageno&"</font>/"&mpage&" 共 "&allshu&" 部漫画&nbsp;"
if cint(pageno)>1 then
pagefy=pagefy&"<a href="&htmlName&".htm title=""首页"">首页</a>"
end if
if cint(pageno)>1 then
if pageno-1=1 then
pagefy=pagefy&"<a href="&htmlName&".htm title=""上一页"">上一页</a>"
else
pagefy=pagefy&"<a href="&htmlName&"_"&pageno-1&".htm title=""上一页"">上一页</a>"
end if
end if

pp=cint(pageno)-2            
  if pp<1 then            
  pp=1            
  end if            
p=0
for pno=pp to mpage
p=p+1
if pno*1=cint(pageno)*1 then
pagefy=pagefy&"<span>"&pno&"</span>"
else
if pno=1 then
pagefy=pagefy&"<a href="""&htmlName&".htm"" title=""第"&pno&"页"">"&pno&"</a>"
else
pagefy=pagefy&"<a href="""&htmlName&"_"&pno&".htm"" title=""第"&pno&"页"">"&pno&"</a>"
end if
end if                                                                        
if p>=5 then exit for            
next
pagefy=pagefy&""
if cint(pageno)< mpage then
pagefy=pagefy&"<a href="&htmlName&"_"&pageno+1&".htm title=""下一页"">下一页</a>"
end if
if cint(pageno)< mpage then
pagefy=pagefy&"<a href="&htmlName&"_"&mpage&".htm title=""末页"">末页</a>"
end if

pagefy=pagefy&"<span class=""dot"">跳转到：第 <select name=""select"" onChange=""javascript:window.location.href=this.options[this.selectedIndex].value""><script> var total_page="&mpage&";var cur_page="&currentPage&";for (i=1;i<=total_page;i++){  if (i == cur_page) {    document.write(""<option selected value="&htmlName&"_""+i+"".htm>""+i+""</option>"");  } else{    document.write(""<option  value="&htmlName&"_""+i+"".htm>""+i+""</option>"");  }}</script></select> 页</span>"
'################ 分页结束 ################

'################ 生成HTML结束 ################
Set fso = Server.CreateObject("Scripting.FileSystemObject")
'set fr=fso.opentextfile(server.mappath("temp/type.htm"))
'pencat=fr.readall
'fr.close
pencat=ReadFromTextFile("temp/type.htm","utf-8")
pencat=commonreplace(pencat)
pencat=replace(pencat,"[TITLE]",title)
pencat=replace(pencat,"[LIST]",list)
pencat=replace(pencat,"[NEW]",comic_new)
pencat=replace(pencat,"[PAGE]",pagefy)

pencat=replace(pencat,"[HITS]",comic_hits)
pencat=replace(pencat,"[ZM]",zm)
pencat=replace(pencat,"[TJ]",comic_tj)
pencat=replace(pencat,"[WEB_NAME]",web_name)
pencat=replace(pencat,"[WEB_URL]",web_url)
pencat=replace(pencat,"[WEB_BA]",miibeian)
pencat=adreplace(pencat)
'Set fout = fso.CreateTextFile(server.mappath("../list/"&filename&".htm"))
'fout.Write pencat
'fout.close
WriteToTextFile "../list/"&filename&".htm",pencat,"utf-8"
'************** 生成HTML页 结束 ***************
%>
%>